package com.heima.model.article.dtos;

import com.heima.model.article.pojos.ApArticle;
import com.heima.model.wemedia.dtos.ArticleDto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class ApArticleDto  extends ApArticle {
    /**
     * 文章内容
     */
    private String content;

    public ApArticleDto(ArticleDto dto) {
        this.setTitle(dto.getTitle());
        //this.setAuthorId((long) 1120);
        //this.setAuthorName("嘉德罗斯");
        this.setLayout((short) 1);
        String[] images = dto.getImages();
        String s = "";
        for (String image : images) {
            s+=image;
            s+=",";
        }
        s = s.substring(0,s.length()-1);
        this.setImages(s);
        this.setLabels(dto.getLabels());
        this.setCreatedTime(new Date());
        this.setPublishTime(new Date());
        this.setSyncStatus(true);
        this.setOrigin(true);
        this.setContent(dto.getContent());
        this.setChannelId(dto.getChannelId());
    }

}